Exits a Do...Loop, For...Next, a function, or a subroutine.
Do...Loop、For...Next、関数、サブルーチンなどを強制的に終了させます。
see Parameters
パラメータを参照
Exit Do
Exit Do
Only valid within a Do...Loop statement to exit the loop. Program execution continues with the statement that follows the Loop statement. If Do...Loop statements are nested, the control is transferred to the loop in the next higher level.
Do...Loop ステートメント内部でのみ使用可能で、ループを強制的に終了させます。プログラムの処理は、終了したループステートメント以降のコードを続行します。Do...Loop ステートメントがネストされている場合、プログラムの処理は、より上位レベルのループに移されます。
Exit For
Exit For
Only valid within a For...Next loop to exit the loop. Program execution continues with the first statement that follows the Next statement. In nested statements, the control is transferred to the loop in the next higher level.
For...Next ステートメント内部でのみ使用可能で、ループを強制的に終了させます。プログラムの処理は、終了した Next ステートメント以降のコードを続行します。ステートメントがネストされている場合、プログラムの処理は、より上位レベルのループに移されます。
Exit Function
Exit Function
Exits the Function procedure immediately. Program execution continues with the statement that follows the Function call.
Function プロシージャーを強制的に終了させます。プログラムの処理は、該当する Function を呼び出したコードの次にあるステートメントから続行されます。
Exit Sub
Exit Sub
Exits the subroutine immediately. Program execution continues with the statement that follows the Sub call.
サブルーチンを強制的に終了させます。プログラムの処理は、該当する Sub を呼び出したコードの次にあるステートメントから続行されます。
![]() | The Exit statement does not define the end of a structure, and must not be confused with the End statement.
この Exit ステートメントは、End ステートメントとは異なり、サブルーチンなどのブロックの終了部を宣言するものではないので注意が必要です。 |
Sub ExampleExit
Sub ExampleExit
Dim sReturn As String
Dim sReturn As String
Dim sListArray(10) as String
Dim sListArray(10) as String
Dim siStep as Single
Dim siStep as Single
For siStep = 0 to 10 REM Fill array with test data
For siStep = 0 to 10 REM 配列にテスト用データを代入
sListArray(siStep) = chr(siStep + 65)
sListArray(siStep) = chr(siStep + 65)
msgbox sListArray(siStep)
msgbox sListArray(siStep)
next siStep
Next siStep
sReturn = LinSearch(sListArray(), "B")
sReturn = LinSearch(sListArray(), "B")
Print sReturn
Print sReturn
end sub
end sub
Function LinSearch( sList(), sItem As String ) as integer
Function LinSearch( sList(), sItem As String ) as integer
dim iCount as Integer
dim iCount as Integer
REM LinSearch searches a TextArray:sList() for a TextEntry:
REM LinSearch はテキスト配列: sList() 内に指定文字列を検索:
REM Returns the index of the entry or 0 ( Null)
REM 戻り値は、該当するインデックス値ないしゼロ (Null)
for iCount=1 to Ubound( sList() )
for iCount=1 to Ubound( sList() )
if sList( iCount ) = sItem then
if sList( iCount ) = sItem then
Exit for REM sItem found
Exit for REM 検索で sItem がヒット
end if
end if
next iCount
Next iCount
if iCount = Ubound( sList() ) then iCount = 0
if iCount = Ubound( sList() ) then iCount = 0
LinSearch = iCount
LinSearch = iCount
end function
end function